package org.jeecgframework.web.service.impl;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;

import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
import org.jeecgframework.web.service.ZyRoomServiceI;
import org.jeecgframework.web.system.pojo.base.ZyRoomEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**   
 * @Title: ZyLinkmanServiceImpl
 * @Description: 影厅信息
 * @author ZhangYunlong
 * @date 2016-04-01
 * @version V1.0   
 *
 */
@Service("zyRoomService")
@Transactional
public class ZyRoomServiceImpl extends CommonServiceImpl implements ZyRoomServiceI {

	
 	public <T> void delete(T entity) {
 		super.delete(entity);
 		//执行删除操作配置的sql增强
		this.doDelSql((ZyRoomEntity)entity);
 	}
 	
 	public <T> Serializable save(T entity) {
 		Serializable t = super.save(entity);
 		//执行新增操作配置的sql增强
// 		this.doAddSql((ZyRoomEntity)entity);
 		return t;
 	}
 	
 	public <T> void saveOrUpdate(T entity) {
 		super.saveOrUpdate(entity);
 		//执行更新操作配置的sql增强
// 		this.doUpdateSql((ZyRoomEntity)entity);
 	}
 	
 	/**
	 * 默认按钮-sql增强-新增操作
	 * @param id
	 * @return
	 */
 	public boolean doAddSql(ZyRoomEntity t){
	 	return true;
 	}
 	/**
	 * 默认按钮-sql增强-更新操作
	 * @param id
	 * @return
	 */
 	public boolean doUpdateSql(ZyRoomEntity t){
	 	return true;
 	}
 	/**
	 * 默认按钮-sql增强-删除操作
	 * @param id
	 * @return
	 */
 	public boolean doDelSql(ZyRoomEntity t){
	 	return true;
 	}
 	
 	/**
	 * 替换sql中的变量
	 * @param sql
	 * @return
	 */
 	public String replaceVal(String sql,ZyRoomEntity t){
 		sql  = sql.replace("#{id}",String.valueOf(t.getId()));
 		sql  = sql.replace("#{room_cinema}",String.valueOf(t.getRoomCinema()));
 		sql  = sql.replace("#{room_num}",String.valueOf(t.getRoomNum()));
 		sql  = sql.replace("#{seat_num}",String.valueOf(t.getSeatNum()));
 		sql  = sql.replace("#{screen_type}",String.valueOf(t.getScreenType()));
 		sql  = sql.replace("#{screen_plus}",String.valueOf(t.getScreenPlus()));
 		sql  = sql.replace("#{screen_width}",String.valueOf(t.getScreenWidth()));
 		sql  = sql.replace("#{screen_hight}",String.valueOf(t.getScreenHight()));
 		sql  = sql.replace("#{curtain_width}",String.valueOf(t.getCurtainWidth()));
 		sql  = sql.replace("#{curtain_hight}",String.valueOf(t.getCurtainHight()));
 		sql  = sql.replace("#{show_km}",String.valueOf(t.getShowKm()));
 		sql  = sql.replace("#{screen_lens_ratio}",String.valueOf(t.getScreenLensRatio()));
 		sql  = sql.replace("#{curtain_lens_ratio}",String.valueOf(t.getCurtainLensRatio()));
 		sql  = sql.replace("#{room_special_case}",String.valueOf(t.getRoomSpecialCase()));
 		sql  = sql.replace("#{is_normal}",String.valueOf(t.getIsNormal()));
 		sql  = sql.replace("#{exception_reason}",String.valueOf(t.getExceptionReason()));
 		sql  = sql.replace("#{create_name}",String.valueOf(t.getCreateName()));
 		sql  = sql.replace("#{create_by}",String.valueOf(t.getCreateBy()));
 		sql  = sql.replace("#{create_date}",String.valueOf(t.getCreateDate()));
 		sql  = sql.replace("#{update_name}",String.valueOf(t.getUpdateName()));
 		sql  = sql.replace("#{update_by}",String.valueOf(t.getUpdateBy()));
 		sql  = sql.replace("#{update_date}",String.valueOf(t.getUpdateDate()));
 		sql  = sql.replace("#{UUID}",UUID.randomUUID().toString());
 		return sql;
 	}

	public List<Map<String, Object>> queryDatagridResultForChooseRoomEquipment(HttpServletRequest request, String belongCinemaId) {
		StringBuffer sql = new StringBuffer();
		sql.append(" SELECT ");
		sql.append(" r.id, r.room_num AS roomNum, r.seat_num AS seatNum ");
		sql.append(" FROM ");
		sql.append(" zy_room r ");
		sql.append(" WHERE ");
		sql.append(" r.room_cinema = '").append(belongCinemaId).append("' ");
		sql.append(" AND (r.is_delete = '0' OR ISNULL(r.is_delete)) ");
		return super.findForJdbc(sql.toString());
	}
	
	
	
	
	
	
	
	
	
	
}